package service

import (
	"BiYeProServer/src/model/dao"
	"BiYeProServer/src/util"
	"encoding/json"
	"fmt"
	"github.com/gin-gonic/gin"
)

func GetRecommend(ctx *gin.Context) {
	name := ctx.Query("user_name")
	user := dao.SelectUserByUname(ctx, name)
	resp := util.CommonGet("http://127.0.0.1:5000/user/recbole/" + fmt.Sprintf("%d", user.Id))
	respMap := map[string]interface{}{}
	if len(resp) > 0 {
		json.Unmarshal([]byte(resp), &respMap)
		fmt.Println(resp)
		util.SetResponse(ctx, 200, true, respMap, "查询成功")
	} else {
		util.SetResponse(ctx, 5020, false, nil, "查询失败")
	}
}
